import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    { path: "/", redirect: "/manager/home" },

    {
      path: "/manager",
      component: () => import("@/views/Manager.vue"),
      children: [
        {
          path: "home",
          meta: { name: "系统首页" },
          component: () => import("@/views/manager/Home.vue"),
        },
        {
          path: "notice",
          meta: { name: "公告栏" },
          component: () => import("@/views/manager/Notice.vue"),
        },
        {
          path: "admin",
          meta: { name: "管理员信息" },
          component: () => import("@/views/manager/Admin.vue"),
        },
        {
          path: "person",
          meta: { name: "个人信息" },
          component: () => import("@/views/manager/Person.vue"),
        },
        {
          path: "password",
          meta: { name: "修改密码" },
          component: () => import("@/views/manager/Password.vue"),
        },
      ],
    },

    {
      path: "/front",
      component: () => import("@/views/Front.vue"),
      children: [
        {
          path: "home",
          component: () => import("@/views/front/Home.vue"),
        },
        {
          path: "person",
          component: () => import("@/views/front/Person.vue"),
        },
      ],
    },

    { path: "/404", component: () => import("@/views/404.vue") },
    { path: "/login", component: () => import("@/views/Login.vue") },
    { path: "/register", component: () => import("@/views/Register.vue") },
    // 当路径不符合其他规则时，跳转到404页面
    { path: "/:pathMatch(.*)*", redirect: "/404" },
  ],
});

export default router;
